home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS03.ADF / Assembler / Argoterm.asm < prev    next >
Assembly Source File  |  1986-04-02  |  51KB  |  3,391 lines

  1. **************************************************************
  2.  
  3. * *                                                        * *
  4.  
  5. * * ATerm 0.20, by Jez San, (c)1986 Argonaut Software Ltd. * *
  6.  
  7. * *                                                        * *
  8.  
  9. * * 129, The Broadway, Mill Hill, London, NW7 4RN, ENGLAND * *
  10.  
  11. * *                                                        * *
  12.  
  13. * *    FrillFree Terminal Software For The Amiga A1000     * *
  14.  
  15. * *                                                        * *
  16.  
  17. * *                     -- Freeware --                     * *
  18.  
  19. * *                                                        * *
  20.  
  21. **************************************************************
  22.  
  23.  
  24.  
  25.  
  26.  
  27. * Some Include files that might be useful (Most aren't!)
  28.  
  29.  
  30.  
  31.          include  "exec/types.i"
  32.  
  33.          include  "exec/funcdef.i"
  34.  
  35.          include  "exec/exec_lib.i"
  36.  
  37.  
  38.  
  39.          include  "libraries/dos.i"
  40.  
  41.          include  "libraries/dos_lib.i"
  42.  
  43.  
  44.  
  45.          include  "devices/serial.i"
  46.  
  47.          include  "devices/narrator.i"
  48.  
  49.  
  50.  
  51. *                    Program History:
  52.  
  53. *                   ------------------
  54.  
  55.  
  56.  
  57. * (Once Upon A Time...) This prog was written on a boring day in January.
  58.  
  59.  
  60.  
  61. * During February, I decided that it should have been completed in January!!
  62.  
  63. * (But It wasn't!).   A Guilt complex set in, but a rare disease known as
  64.  
  65. * 'PAID WORK' caused me to spend my time trying to complete my arcade game
  66.  
  67. * for BT RAINBIRD, called "STARGLIDER"  (a 3d space battle simulator)
  68.  
  69.  
  70.  
  71. * Pressure from CBM Sysops on PLINK (thanks Harv!) made me add the final
  72.  
  73. * tweaks, and.. (suspense.....) Here it is, the first talking terminal!
  74.  
  75.  
  76.  
  77. * Disclaimers:
  78.  
  79.  
  80.  
  81. * I haven't read the Intuition manual yet, and thus there isn't a friendly
  82.  
  83. * user-interface in this program (.. yet!)  I will add it... eventually.
  84.  
  85.  
  86.  
  87. * PLEASE, People!! Improve this program!!  Ensure that it is in the
  88.  
  89. * Public domain, but feel free to add lotsa fun features to this 'frill
  90.  
  91. * free' Terminal program.
  92.  
  93.  
  94.  
  95. * Above all, this program was an exercise for me to learn about Amiga's OS
  96.  
  97. * and how to use it.  Unfortunately, machine code usage of Amiga OS is
  98.  
  99. * very poorly documented... All the manuals assume a working knowledge
  100.  
  101. * of 'C', but unfortunately (for me) I have not learned this language.
  102.  
  103.  
  104.  
  105. *  I had fun writing this; hope You enjoy using it.
  106.  
  107.  
  108.  
  109. *                    ---  Jez San,
  110.  
  111. *
  112.  
  113. *                      London, England.
  114.  
  115.  
  116.  
  117. * Tracking me down...
  118.  
  119. * In USA -> CIS '72247,3661', BIX 'jsan', PLINK 'UK JEZ', Source 'BCD776',
  120.  
  121. * In UK -> Prestel, '919991062', MUD 'Jez'.
  122.  
  123.  
  124.  
  125.  
  126.  
  127. * -------------------------------------------------------------- *
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135. *  A Macro, cos I'm lazy at typing...
  136.  
  137.  
  138.  
  139. print    macro    * handle,messagepointer
  140.  
  141.          move.l   \1,d1
  142.  
  143.          lea      \2(PC),a0
  144.  
  145.          bsr      message
  146.  
  147.          endm
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155. * Arbitrary Equates, and his pal; Label Definitions
  156.  
  157.  
  158.  
  159. sysbase  equ      $4                Base Pointer to the Exec
  160.  
  161. csi      equ      $9b               Control Sequence Introducer
  162.  
  163. keytime  equ      500               us timeout
  164.  
  165. myflags  equ      SERF_SHARED+SERF_XDISABLED+SERF_RAD_BOOGIE
  166.  
  167.  
  168.  
  169. * Popular Character Definitions
  170.  
  171.  
  172.  
  173. lf       equ      $a                Our Old Favourites!
  174.  
  175. cr       equ      $d
  176.  
  177. xon      equ      $11               CtrlQ
  178.  
  179. xoff     equ      $13               CtrlS
  180.  
  181. esc      equ      $1b
  182.  
  183. space    equ      $20
  184.  
  185.  
  186.  
  187. * Xmodem Definitions
  188.  
  189.  
  190.  
  191. soh      equ      $01               Start Of Header
  192.  
  193. eot      equ      $04               End Of Transmission
  194.  
  195. ack      equ      $06               Acknowledge
  196.  
  197. nak      equ      $15               No Acknowledge
  198.  
  199. can      equ      $18               Cancel
  200.  
  201.  
  202.  
  203. _LVOTranslate  equ   -30            Undefined in my Library file! Hope your
  204.  
  205. *                                   INCLUDE files are better than mine!
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213. * .. And not forgetting The Program
  214.  
  215.  
  216.  
  217.  
  218.  
  219. startup  move.l   sp,saveSP        Save the stack pointer, just in case
  220.  
  221.          move.l   4(sp),d0         Size of our allocated Stack
  222.  
  223.  
  224.  
  225. * Point to our allocated memory (STACK! and bss)
  226.  
  227.  
  228.  
  229.          move.l   sp,a0             Current stack
  230.  
  231.          sub.l    #endbss-startbss+256,d0
  232.  
  233.          sub.l    d0,a0             Subtract our allowance to find start
  234.  
  235.          sub.l    #256,d0           Subtract safety margin Length
  236.  
  237.          and.w    #$ffff-3,d0       Mask to a Long Word boundary
  238.  
  239.          move.l   a0,bufstart       Start of Buffer value
  240.  
  241.          move.l   d0,buflen         Length of buffer value
  242.  
  243.  
  244.  
  245. * Open DOS library.
  246.  
  247.  
  248.  
  249.          move.l   sysbase,a6        Pointer to Exec Library
  250.  
  251.          lea      thedos(pc),a1     Point to title of DOS
  252.  
  253.          moveq    #0,d0             Version number
  254.  
  255.          jsr      _LVOOpenLibrary(a6)
  256.  
  257.          move.l   d0,dosbase        DOS library Pointer
  258.  
  259.          beq      openerr           Error, can't open library!
  260.  
  261.  
  262.  
  263. * Open Translator library.
  264.  
  265.  
  266.  
  267.          lea      thetrans(pc),a1   Point to title of Translator
  268.  
  269.          moveq    #0,d0             Version
  270.  
  271.          jsr      _LVOOpenLibrary(a6)
  272.  
  273.          move.l   d0,tranbase
  274.  
  275.          beq      openerr
  276.  
  277.  
  278.  
  279.  
  280.  
  281. * Open Console for I/O.
  282.  
  283.  
  284.  
  285.          lea      conname(pc),a1    Point to console definition text
  286.  
  287.          bsr      openfile          Open a DOS file
  288.  
  289.          beq      openerr
  290.  
  291.          move.l   d0,chandle        Console Handle
  292.  
  293.  
  294.  
  295. * Find what task we are in, and install it in the msg ports
  296.  
  297.  
  298.  
  299.          sub.l    a1,a1             We want *MY* task
  300.  
  301.          move.l   sysbase,a6        Exec Lib Ptr
  302.  
  303.          jsr      _LVOFindTask(a6)
  304.  
  305.  
  306.  
  307.          move.l   d0,MP_SIGTASK+write_reply
  308.  
  309.          move.l   d0,MP_SIGTASK+read_reply
  310.  
  311.          move.l   d0,MP_SIGTASK+nwriterep
  312.  
  313.  
  314.  
  315. * Add three Message Ports to the system, one for Input, one for Output,
  316.  
  317. * and one for Narrator.
  318.  
  319.  
  320.  
  321.          lea      read_reply,a1     Message Port
  322.  
  323.          jsr      _LVOAddPort(a6)   Add another Port to list
  324.  
  325.  
  326.  
  327.          lea      write_reply,a1    Repeat procedure for another Port
  328.  
  329.          jsr      _LVOAddPort(a6)
  330.  
  331.  
  332.  
  333.          lea      nwriterep,a1      Add the Narrator message port
  334.  
  335.          jsr      _LVOAddPort(a6)
  336.  
  337.  
  338.  
  339.  
  340.  
  341. * Open Serial.Device for Input
  342.  
  343.  
  344.  
  345.          lea      readreq,a1              IRequest area
  346.  
  347.          move.b   #myflags,IO_SERFLAGS(a1)
  348.  
  349.          move.l   #read_reply,$E(a1)      !!! Message.MN_REPLYPORT undefined
  350.  
  351.  
  352.  
  353.          moveq    #0,d0                   UnitNumber, ignored.
  354.  
  355.          moveq    #0,d1                   Flags, ignored.
  356.  
  357.          lea      serdevice(pc),a0        Point to the Device Name
  358.  
  359.  
  360.  
  361.          jsr      _LVOOpenDevice(a6)      Open it
  362.  
  363.          tst.l    d0                      Did it Open Okay?
  364.  
  365.          bne      openerr                 Zero is Successful (consistent!!?)
  366.  
  367.  
  368.  
  369. * Open Serial.Device for Output
  370.  
  371.  
  372.  
  373.          lea      writereq,a1             ORequest area
  374.  
  375.          move.b   #myflags,IO_SERFLAGS(a1)
  376.  
  377.          move.l   #write_reply,$E(a1)     Message.NN_REPLYPORT
  378.  
  379.  
  380.  
  381.          moveq    #0,d0
  382.  
  383.          moveq    #0,d1
  384.  
  385.          lea      serdevice(pc),a0        Device definition
  386.  
  387.  
  388.  
  389.          jsr      _LVOOpenDevice(a6)
  390.  
  391.          tst.l    d0
  392.  
  393.          bne      openerr
  394.  
  395.  
  396.  
  397. * Open Narrator device.
  398.  
  399.  
  400.  
  401.          lea      talkio,a1               Talk request block
  402.  
  403.          moveq    #0,d0                   Unit Number=0
  404.  
  405.          moveq    #0,d1                   Device number=0
  406.  
  407.          lea      nardevice(pc),a0        Device definition
  408.  
  409.  
  410.  
  411.          jsr      _LVOOpenDevice(a6)
  412.  
  413.          tst.l    d0
  414.  
  415.          bne      openerr
  416.  
  417.  
  418.  
  419. * Initialise the Narrator
  420.  
  421.  
  422.  
  423.          lea      talkio,a1               Talk Output request area
  424.  
  425.          move.l   #nwriterep,$E(a1)       Find the message port!
  426.  
  427.          move.l   #amaps,NDI_CHMASKS(a1)  Audio Channel Masks
  428.  
  429.          move.w   #4,NDI_NUMMASKS(a1)     Number of channels
  430.  
  431.          move.w   #210,NDI_RATE(a1)       Make it talk faster than average!
  432.  
  433.  
  434.  
  435. * Initialise the serial port here...
  436.  
  437.  
  438.  
  439.          lea      writereq,a1             Point to request block
  440.  
  441.          move.b   #8,IO_READLEN(a1)
  442.  
  443.          move.b   #8,IO_WRITELEN(a1)
  444.  
  445.          move.l   #0,IO_CTLCHAR(a1)       Should set to zero perhaps!?
  446.  
  447.          move.b   #myflags,IO_SERFLAGS(a1)
  448.  
  449.          move.w   #SDCMD_SETPARAMS,IO_COMMAND(a1)
  450.  
  451.  
  452.  
  453.          move.l   sysbase,a6
  454.  
  455.          jsr      _LVODoIO(a6)            Send it!
  456.  
  457.  
  458.  
  459.          bsr      initser
  460.  
  461.  
  462.  
  463.          print    chandle,welcome         Display the welcome Message
  464.  
  465.  
  466.  
  467. * Initialise a few variables
  468.  
  469.  
  470.  
  471.          st       squalking         Turn squalking off as default
  472.  
  473.          clr.b    fileflag          No file Transfer going on
  474.  
  475.          move.l   bufstart,bufptr   Buffer Empty
  476.  
  477.          clr.b    duplex            Default = Full Duplex
  478.  
  479.          clr.l    lengthin          No text in speech buffer
  480.  
  481.          move.l   #intext,textptr   Initial buffer pointer
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489. * The Main loop!
  490.  
  491.  
  492.  
  493. mainloop bsr      scankey           User type a key?
  494.  
  495.          beq      notkeyu           Nope
  496.  
  497.  
  498.  
  499.          cmp.b    #csi,d0           Did User press a function key?
  500.  
  501.          beq      trycsi            Yes, so print up the menu
  502.  
  503.  
  504.  
  505. * -- Decode Function Keys here, if necessary!  --
  506.  
  507.  
  508.  
  509.          tst.b    duplex            Full or Half Duplex?
  510.  
  511.          beq.s    fulldup           Z=Full Duplex
  512.  
  513.          bsr      wrchar            Local echo
  514.  
  515. fulldup  bsr      sendser           Send the character
  516.  
  517. notkeyu  move.b   fileflag,d0       Are we Uploading the Buffer?
  518.  
  519.          cmp.b    #'U',d0           Yes??
  520.  
  521.          bne.s    notkey1           Nope!
  522.  
  523.  
  524.  
  525.          move.l   ubufptr,a0        Get Upload pointer
  526.  
  527.          move.l   bufptr,a1         Get Normal Buffer Pointer
  528.  
  529.          cmp.l    a1,a0             How are we doing?
  530.  
  531.          bge.s    finupl            Must have finished!
  532.  
  533.          move.b   (a0)+,d1          Get next character to Upload
  534.  
  535.          move.l   a0,ubufptr        Increment Upload buffer pointer
  536.  
  537.          bsr      sendser           Send the character
  538.  
  539.          bra.s    notkey1           ... and continue
  540.  
  541. finupl   clr.b    fileflag          Discontinue the Upload sequence
  542.  
  543. notkey1  bsr      scanser           Any chars waiting on the Ser port?
  544.  
  545.          bmi.s    mainloop          Nope, nothing there!
  546.  
  547.          and.w    #$7f,d0           Mask out Parity bit (Ignore Parity!)
  548.  
  549.          bsr      wrchar            Print it on the screen
  550.  
  551.  
  552.  
  553.          cmp.l    #255,lengthin     If buffer full, dont buffer anymore
  554.  
  555.          beq      dosqualk
  556.  
  557.          move.l   textptr,a0        Put character into Text buffer
  558.  
  559.          move.b   d0,(a0)+          ready for speech
  560.  
  561.          move.l   a0,textptr
  562.  
  563.          addq.l   #1,lengthin
  564.  
  565.  
  566.  
  567.          cmp.b    #cr,d0            Was it end of line?
  568.  
  569.          bne.s    nsqualk1          If so, Squalk it!
  570.  
  571. dosqualk bsr      squalk
  572.  
  573.  
  574.  
  575. nsqualk1 cmp.b    #'D',fileflag     Are we downloading text?
  576.  
  577.          bne      mainloop          Nope!
  578.  
  579.  
  580.  
  581.          move.l   bufptr,a0         We ARE downloading, so Where Buffer?
  582.  
  583.          move.b   d0,(a0)+          Insert Character into Buffer
  584.  
  585.          move.l   a0,bufptr         Increment buffer
  586.  
  587.  
  588.  
  589. * Test for Buffer Overflow?    Not properly implemented yet!
  590.  
  591.          move.l   a0,a1
  592.  
  593.          sub.l    bufstart,a1       current-start = Length
  594.  
  595.          cmp.l    buflen,a1         Is it too big?
  596.  
  597.          bcc      warnsave          Force user to Save Buffer if too big!
  598.  
  599.  
  600.  
  601.          bra      mainloop          .. And continue for more!
  602.  
  603.  
  604.  
  605. * User pressed a Special key, generating a Control Sequence Introducer
  606.  
  607.  
  608.  
  609. trycsi   bsr      rdchar            Get the next character
  610.  
  611.          cmp.b    #'?',d0           Was it HELP?
  612.  
  613.          bne.s    morecsi
  614.  
  615.  
  616.  
  617.          bsr      rdchar            Get next char
  618.  
  619.          cmp.b    #'~',d0           Caret is end of sequence
  620.  
  621.          beq      trymenu
  622.  
  623.          bra      mainloop
  624.  
  625.  
  626.  
  627. morecsi  bra      mainloop          Test for Function Keys here!
  628.  
  629.  
  630.  
  631.  
  632.  
  633. * User pressed HELP key, to display the menu
  634.  
  635.  
  636.  
  637. trymenu  bsr      sendxoff
  638.  
  639.  
  640.  
  641. * Open a new window stacked on top of the old one, for displaying
  642.  
  643. * the Menu.
  644.  
  645.  
  646.  
  647.          lea      conname(pc),a1    Point to console definition text
  648.  
  649.          bsr      openfile          Open it
  650.  
  651.          beq      openerr
  652.  
  653.          move.l   d0,mhandle        Console Window's handle
  654.  
  655.  
  656.  
  657. * Display the menu!
  658.  
  659.  
  660.  
  661. menuagn  print    mhandle,menutext  Display the menu
  662.  
  663.  
  664.  
  665.          bsr      infobuf           How many characters in buffer?
  666.  
  667.  
  668.  
  669. menuagn2 bsr      rdmenu            Get a key from Menu Console
  670.  
  671.  
  672.  
  673.          cmp.b    #esc,d0           Escape key pressed?
  674.  
  675.          beq      menuexit          So Return back to Terminal
  676.  
  677.  
  678.  
  679.          and.w    #$df,d0           Mask out Lower Case
  680.  
  681.          cmp.b    #'Q',d0           Q for Quit?
  682.  
  683.          beq      termmenu
  684.  
  685.          cmp.b    #'B',d0           B for Baudrate?
  686.  
  687.          beq      setbaud
  688.  
  689.          cmp.b    #'C',d0           C for Clear?
  690.  
  691.          beq      doclear
  692.  
  693.          cmp.b    #'D',d0           D for Download?
  694.  
  695.          beq      dodownl
  696.  
  697.          cmp.b    #'E',d0           E for Echo?
  698.  
  699.          beq      localec
  700.  
  701.          cmp.b    #'L',d0           L for Load Buffer?
  702.  
  703.          beq      loadbuf
  704.  
  705.          cmp.b    #'U',d0           U for Upload Buffer?
  706.  
  707.          beq      uplode
  708.  
  709.          cmp.b    #'X',d0           X for Xmodem Transfer?
  710.  
  711.          beq      xmodem
  712.  
  713.          cmp.b    #'T',d0           T for Talk mode?
  714.  
  715.          beq      talkmode
  716.  
  717.  
  718.  
  719.          bra      menuagn2          Go back for another choice perhaps?
  720.  
  721.  
  722.  
  723. menuexit bsr.s    closemenu         Close the menu console
  724.  
  725.          bsr      sendxon           Send an Xon to resmue host xmission
  726.  
  727.  
  728.  
  729.          bra      mainloop          Now back to the Terminal!
  730.  
  731.  
  732.  
  733. termmenu bsr.s    closemenu         Close the Menu console
  734.  
  735.          bra      terminate         Quit the program!
  736.  
  737.  
  738.  
  739.  
  740.  
  741. * Close the Menu Console window
  742.  
  743.  
  744.  
  745. closemenu
  746.  
  747.          move.l   mhandle,d1        Close the Menu window
  748.  
  749.          move.l   dosbase,a6        Dos library
  750.  
  751.          jmp      _LVOClose(a6)
  752.  
  753.  
  754.  
  755.  
  756.  
  757. * Clear the Capture Buffer
  758.  
  759.  
  760.  
  761. clear    move.l   bufstart,bufptr
  762.  
  763.          bra      trymenu
  764.  
  765.  
  766.  
  767.  
  768.  
  769. * Change the baud rate
  770.  
  771.  
  772.  
  773.  
  774.  
  775. * Clear the buffer
  776.  
  777.  
  778.  
  779. doclear  move.l   bufstart,bufptr
  780.  
  781.          bra      menuagn
  782.  
  783.  
  784.  
  785. * Start the Download in process
  786.  
  787.  
  788.  
  789. dodownl  move.b   fileflag,d0       Are we already downloading?
  790.  
  791.          cmp.b    #'D',d0           Yes??
  792.  
  793.          beq.s    down2             if so, stop downloading, and save buf!
  794.  
  795.  
  796.  
  797. * Print up a message saying that downloading is ON!  and do it!
  798.  
  799.  
  800.  
  801.          print    mhandle,down1m
  802.  
  803.  
  804.  
  805.          move.b   #'D',fileflag        Flag saying Download is on!
  806.  
  807.          move.l   bufstart,bufptr      Clear buffer contents!
  808.  
  809.  
  810.  
  811.          bra      menuagn              Go back to Main Loop
  812.  
  813.  
  814.  
  815. * Downloading must be turned OFF here, and buffer saved.
  816.  
  817.  
  818.  
  819. down2    move.l   bufptr,a0            Was there anything in the buffer?
  820.  
  821.          cmp.l    bufstart,a0          Yes?
  822.  
  823.          beq      down3                Turn off downloader, anyway!
  824.  
  825.  
  826.  
  827.          bsr      savebuf              Save the buffer
  828.  
  829.          bne      menuagn
  830.  
  831.  
  832.  
  833. down3    clr.b    fileflag             Stop Downloading,
  834.  
  835.          move.l   bufstart,bufptr      and clear buffer
  836.  
  837.  
  838.  
  839.          print    mhandle,down2m       Tell user that Download is OFF
  840.  
  841.  
  842.  
  843.          bra      menuagn              Go back to Main Loop
  844.  
  845.  
  846.  
  847. * Toggle the Local Echo mode
  848.  
  849.  
  850.  
  851. localec  print    mhandle,nowset2m
  852.  
  853.  
  854.  
  855.          not.b    duplex               Invert state
  856.  
  857.          beq.s    showfull
  858.  
  859.  
  860.  
  861. * Half duplex...
  862.  
  863.  
  864.  
  865.          print    mhandle,halfm
  866.  
  867.          bra      menuagn
  868.  
  869.  
  870.  
  871. * Full duplex...
  872.  
  873.  
  874.  
  875. showfull print    mhandle,fullm
  876.  
  877.          bra      menuagn              Back to the Menu
  878.  
  879.  
  880.  
  881.  
  882.  
  883. talkmode not.b    squalking
  884.  
  885.          beq.s    issqualk
  886.  
  887.  
  888.  
  889.          print    mhandle,notsqm
  890.  
  891.          bra      menuagn
  892.  
  893.  
  894.  
  895. issqualk print    mhandle,yessqm
  896.  
  897.          bra      menuagn
  898.  
  899.  
  900.  
  901.  
  902.  
  903. * Start an Upload
  904.  
  905.  
  906.  
  907. uplode   move.b   fileflag,d0          Are we already uploading?
  908.  
  909.          cmp.b    #'U',d0              Yes??
  910.  
  911.          beq      alredu               tell'em we already are!
  912.  
  913.  
  914.  
  915.          move.l   bufptr,a0            Anything in buffer?
  916.  
  917.          move.l   bufstart,a1          Start of buffer
  918.  
  919.          cmp.l    a0,a1                forget it if nothing in buffer
  920.  
  921.          beq      exitu1
  922.  
  923.  
  924.  
  925.          move.b   #'U',fileflag        Flag an Uplo0ad in progress
  926.  
  927.          move.l   a0,ubufptr           Point the Upload buffer to text.
  928.  
  929.  
  930.  
  931.          print    mhandle,upld1m       Tell user that Upload has started
  932.  
  933.  
  934.  
  935. exitu1   bra      menuagn              Go back to Main Loop
  936.  
  937.  
  938.  
  939. * Tell the User they are very naughty indeed!
  940.  
  941.  
  942.  
  943. alredu   print    mhandle,upld2m
  944.  
  945.  
  946.  
  947.          bra      menuagn              Back to Menu time!
  948.  
  949.  
  950.  
  951.  
  952.  
  953. * Display how many characters in Buffer
  954.  
  955.  
  956.  
  957. infobuf  move.l   bufptr,d0         Current buffer pointer - start = length
  958.  
  959.          sub.l    bufstart,d0
  960.  
  961.          bsr      bin2decl
  962.  
  963.  
  964.  
  965.          print    mhandle,infmess1
  966.  
  967.  
  968.  
  969.          move.l   buflen,d0
  970.  
  971.          bsr      bin2decl
  972.  
  973.  
  974.  
  975.          print    mhandle,infmess2
  976.  
  977.          rts
  978.  
  979.  
  980.  
  981.  
  982.  
  983. warnsave print    chandle,warnmes
  984.  
  985.          bsr      rdchar
  986.  
  987.          bra      trymenu
  988.  
  989.  
  990.  
  991.  
  992.  
  993. * Save the Buffer out to disk and Clear it.
  994.  
  995.  
  996.  
  997. savebuf  bsr      filename
  998.  
  999.          beq      badsave
  1000.  
  1001.  
  1002.  
  1003.          bsr      openup
  1004.  
  1005.          beq      badsave
  1006.  
  1007.          bsr      writefile
  1008.  
  1009.          bsr      closefile
  1010.  
  1011.          moveq    #0,d0          Signal an OKAY save.
  1012.  
  1013.          rts
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019. * Load Buffer from disk
  1020.  
  1021.  
  1022.  
  1023. loadbuf  bsr      filename
  1024.  
  1025.          beq      badload
  1026.  
  1027.  
  1028.  
  1029. * Zero out entire buffer area prior to loading a flie
  1030.  
  1031.          move.l   bufstart,a0
  1032.  
  1033.          move.l   buflen,d0
  1034.  
  1035.          lsr.l    #2,d0
  1036.  
  1037.  
  1038.  
  1039. bufclrlp clr.l    (a0)+
  1040.  
  1041.          subq.l   #1,d0
  1042.  
  1043.          bne.s    bufclrlp
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.          bsr      openit
  1050.  
  1051.          beq      badload
  1052.  
  1053.  
  1054.  
  1055.          bsr      readfile
  1056.  
  1057.          bsr      closefile
  1058.  
  1059.  
  1060.  
  1061.          bra      menuagn
  1062.  
  1063.  
  1064.  
  1065. badload  print    mhandle,bloadmes
  1066.  
  1067.          bra      menuagn
  1068.  
  1069.  
  1070.  
  1071. badsave  print    mhandle,bsavemes
  1072.  
  1073.          moveq    #-1,d0
  1074.  
  1075.          rts
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081. * Requests a filename
  1082.  
  1083.  
  1084.  
  1085. filename print    mhandle,filemes
  1086.  
  1087.          bsr      getline         Get a line of text
  1088.  
  1089.  
  1090.  
  1091. * Copy over filename from input buffer to file buffer
  1092.  
  1093.  
  1094.  
  1095.          lea      inputbuf,a2
  1096.  
  1097.          lea      filehead,a3
  1098.  
  1099.          moveq    #32,d2
  1100.  
  1101. copylp1  move.b   (a2)+,(a3)+
  1102.  
  1103.          dbra     d2,copylp1
  1104.  
  1105.  
  1106.  
  1107.          move.b   #13,d0
  1108.  
  1109.          bsr      wrmenu
  1110.  
  1111.          move.b   #10,d0
  1112.  
  1113.          bsr      wrmenu
  1114.  
  1115.  
  1116.  
  1117.          tst.b    inputbuf       Will be zero if no entry
  1118.  
  1119.  
  1120.  
  1121.          rts
  1122.  
  1123.  
  1124.  
  1125. * Gets a line of text from the user
  1126.  
  1127.  
  1128.  
  1129. getline  lea      inputbuf,a2
  1130.  
  1131.          clr.l    (a2)           Zero the first bit
  1132.  
  1133.  
  1134.  
  1135. getlin1  bsr      rdmenu         Get keyboard Input
  1136.  
  1137.          cmp.b    #8,d0          Backspace
  1138.  
  1139.          beq      backspace
  1140.  
  1141.          cmp.b    #127,d0        Delete
  1142.  
  1143.          beq      backspace
  1144.  
  1145.          bsr      wrmenu         Display it onscreen
  1146.  
  1147.          cmp.b    #13,d0         Return?
  1148.  
  1149.          beq      creturn
  1150.  
  1151.          move.b   d0,(a2)+       Put character into buffer
  1152.  
  1153.          bra      getlin1
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159. * Return pressed... put a Null to terminate, and exit with d0=num of chars.
  1160.  
  1161. creturn  clr.b    (a2)+
  1162.  
  1163.          sub.l    #inputbuf,a2
  1164.  
  1165.          move.l   a2,d0
  1166.  
  1167.          rts
  1168.  
  1169.  
  1170.  
  1171. backspace
  1172.  
  1173.          cmp.l    #inputbuf,a2   Dont allow backspacing before the Start
  1174.  
  1175.          beq      getlin1
  1176.  
  1177.          move.b   #8,d0          Space
  1178.  
  1179.          bsr      wrmenu
  1180.  
  1181.          move.b   #32,d0         Space
  1182.  
  1183.          bsr      wrmenu
  1184.  
  1185.          move.b   #8,d0          Backspace
  1186.  
  1187.          bsr      wrmenu
  1188.  
  1189.          clr.b    (a2)           Zero the current character
  1190.  
  1191.          subq.l   #1,a2          Backtrack one character
  1192.  
  1193.          bra      getlin1
  1194.  
  1195.  
  1196.  
  1197. * Read in an entire file
  1198.  
  1199.  
  1200.  
  1201. readfile move.l   fhandle,d1           Handle of the flie
  1202.  
  1203.  
  1204.  
  1205.          move.l   bufstart,d2          Where to put the data
  1206.  
  1207.          move.l   buflen,d3            Length
  1208.  
  1209.          move.l   dosbase,a6           Library ptr
  1210.  
  1211.          jsr      _LVORead(a6)         Get the text from the file
  1212.  
  1213.  
  1214.  
  1215. * Update length of file to represent amount of text read
  1216.  
  1217.  
  1218.  
  1219.          move.l   bufstart,d1          Get start of buffer
  1220.  
  1221.          add.l    d0,d1                Add number of characters in file
  1222.  
  1223.          move.l   d1,bufptr            Save result as End of buffer
  1224.  
  1225.  
  1226.  
  1227.          rts
  1228.  
  1229.  
  1230.  
  1231. * Write out an entire file
  1232.  
  1233.  
  1234.  
  1235. writefile move.l  fhandle,d1           Handle of File
  1236.  
  1237.  
  1238.  
  1239.          move.l   bufstart,d2          Start of Buffer
  1240.  
  1241.          move.l   bufptr,d3            length = End of Buffer
  1242.  
  1243.          sub.l    bufstart,d3          Subtract Start of buffer = Length
  1244.  
  1245.          move.l   dosbase,a6           Library ptr
  1246.  
  1247.          jmp      _LVOWrite(a6)        Write the text to the console window
  1248.  
  1249.  
  1250.  
  1251. * Close the file
  1252.  
  1253.  
  1254.  
  1255. closefile move.l   fhandle,d1       Close the Menu window
  1256.  
  1257.          move.l   dosbase,a6        Dos library
  1258.  
  1259.          jmp      _LVOClose(a6)
  1260.  
  1261.  
  1262.  
  1263. * Open the file
  1264.  
  1265.  
  1266.  
  1267. openit   lea      filehead,a1
  1268.  
  1269.          bsr      openfile
  1270.  
  1271.          move.l   d0,fhandle
  1272.  
  1273.          tst.l    d0
  1274.  
  1275.          rts
  1276.  
  1277.  
  1278.  
  1279. * Open file for updating
  1280.  
  1281.  
  1282.  
  1283. openup   lea      filehead,a1
  1284.  
  1285.          bsr      openwrite
  1286.  
  1287.          move.l   d0,fhandle
  1288.  
  1289.          tst.l    d0
  1290.  
  1291.          rts
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305. * Flush Serial Port, to ensure internal buffer is M.T.
  1306.  
  1307.  
  1308.  
  1309. flushser bsr      scanser        Try and get some characters from port
  1310.  
  1311.          bpl.s    flushser       If we get some, it aint M.T.
  1312.  
  1313.          rts
  1314.  
  1315.  
  1316.  
  1317. * Xmodem file transfer bits
  1318.  
  1319.  
  1320.  
  1321. xmodem   print    mhandle,xmes1
  1322.  
  1323.  
  1324.  
  1325.          bsr      rdmenu
  1326.  
  1327.          and.w    #$df,d0
  1328.  
  1329.          cmp.b    #'U',d0
  1330.  
  1331.          beq      xmodemup
  1332.  
  1333.          cmp.b    #'D',d0
  1334.  
  1335.          beq      xmodemdn
  1336.  
  1337.  
  1338.  
  1339.          bra      menuagn
  1340.  
  1341.  
  1342.  
  1343. xmodemup print    mhandle,exitmess
  1344.  
  1345.  
  1346.  
  1347.          bsr      sendxon           Get host transmitting again
  1348.  
  1349.  
  1350.  
  1351.          move.l   bufstart,a4       Start of Xmodem buffer
  1352.  
  1353.          moveq    #1,d2             Block number
  1354.  
  1355.  
  1356.  
  1357. * Start by waiting for an initial NAK from the receive side
  1358.  
  1359.  
  1360.  
  1361. xmodeup0 print    mhandle,upmes1
  1362.  
  1363.  
  1364.  
  1365.          move.w   #20,d6            Timeout
  1366.  
  1367.          bsr      waitser
  1368.  
  1369.          bmi.s    xsendblk
  1370.  
  1371.          cmp.b    #nak,d0
  1372.  
  1373.          bne.s    xmodeup0
  1374.  
  1375.  
  1376.  
  1377. * Check for End of file here
  1378.  
  1379.  
  1380.  
  1381. xsendblk move.b   d2,block
  1382.  
  1383.          bsr      scanmenu       Does User want to cancel?
  1384.  
  1385.          bne      xcancel
  1386.  
  1387.          move.b   block,d2
  1388.  
  1389.  
  1390.  
  1391.          move.l   bufptr,a0      Are we at end of buffer?
  1392.  
  1393.          cmp.l    a4,a0
  1394.  
  1395.          ble      finxup
  1396.  
  1397.  
  1398.  
  1399.          bsr      prblock
  1400.  
  1401.          clr.b    d3             Checksum
  1402.  
  1403.  
  1404.  
  1405.          move.b   #soh,d0        Start of block
  1406.  
  1407.          bsr      sendser
  1408.  
  1409.  
  1410.  
  1411.          move.b   d2,d0
  1412.  
  1413.          bsr      sendser        Block number
  1414.  
  1415.          move.b   d2,d0
  1416.  
  1417.          not.b    d0
  1418.  
  1419.          bsr      sendser
  1420.  
  1421.  
  1422.  
  1423.          move.w   #127,d4        Counter for block
  1424.  
  1425. xmodeulp move.b   (a4)+,d0       Get a byte
  1426.  
  1427.          add.b    d0,d3          Compute checksum
  1428.  
  1429.          bsr      sendser
  1430.  
  1431.          dbra     d4,xmodeulp
  1432.  
  1433.  
  1434.  
  1435.          move.b   d3,d0       Send checksum
  1436.  
  1437.          bsr      sendser
  1438.  
  1439.  
  1440.  
  1441. wait20s  move.w   #20,d6         Wait 20 seconds
  1442.  
  1443.          bsr      waitser
  1444.  
  1445.          bmi.s    upnogood
  1446.  
  1447.  
  1448.  
  1449.          cmp.b    #ack,d0
  1450.  
  1451.          beq.s    upgonext
  1452.  
  1453.          cmp.b    #can,d0
  1454.  
  1455.          beq.s    xcancel
  1456.  
  1457.  
  1458.  
  1459.          cmp.b    #nak,d0
  1460.  
  1461.          bne.s    wait20s
  1462.  
  1463.  
  1464.  
  1465. upnogood print    mhandle,uperr1
  1466.  
  1467.  
  1468.  
  1469. uretry   sub.l    #128,a4        Backtrack a block
  1470.  
  1471.          bra      xsendblk
  1472.  
  1473.  
  1474.  
  1475. upgonext addq.b   #1,d2              Increase block number
  1476.  
  1477.          bra      xsendblk
  1478.  
  1479.  
  1480.  
  1481. finxup   move.b   #eot,d0
  1482.  
  1483.          bsr      sendser
  1484.  
  1485.  
  1486.  
  1487. finxup1  move.w   #20,d6
  1488.  
  1489.          bsr      waitser
  1490.  
  1491.          bmi.s    finxup
  1492.  
  1493.          cmp.b    #ack,d0
  1494.  
  1495.          beq.s    finxup2
  1496.  
  1497.          bra.s    finxup1
  1498.  
  1499.  
  1500.  
  1501. finxup2  print    mhandle,updun1
  1502.  
  1503.  
  1504.  
  1505.          bra      menuagn
  1506.  
  1507.  
  1508.  
  1509. xcancel  print    mhandle,cancmes
  1510.  
  1511.          bsr      rdmenu
  1512.  
  1513.          bsr      nlmenu
  1514.  
  1515.          and.w    #$df,d0
  1516.  
  1517.          cmp.b    #'Y',d0
  1518.  
  1519.          beq      uretry
  1520.  
  1521.          move.b   #can,d0
  1522.  
  1523.          bsr      sendser
  1524.  
  1525.          bra      menuagn
  1526.  
  1527.  
  1528.  
  1529. nlmenu   move.l   d0,-(sp)
  1530.  
  1531.          move.b   #13,d0
  1532.  
  1533.          bsr      wrmenu
  1534.  
  1535.          move.b   #10,d0
  1536.  
  1537.          bsr      wrmenu
  1538.  
  1539.          move.l   (sp)+,d0
  1540.  
  1541.          rts
  1542.  
  1543.  
  1544.  
  1545. xrcancel print    mhandle,cancmes
  1546.  
  1547.  
  1548.  
  1549.          bsr      rdmenu
  1550.  
  1551.          bsr      nlmenu
  1552.  
  1553.          and.w    #$df,d0
  1554.  
  1555.          cmp.b    #'Y',d0
  1556.  
  1557.          beq      xreclp0
  1558.  
  1559.          move.b   #can,d0
  1560.  
  1561.          bsr      sendser
  1562.  
  1563.          bra      menuagn
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569. xmodemdn print    mhandle,exitmess
  1570.  
  1571.  
  1572.  
  1573.          bsr      sendxon           Get host moving again
  1574.  
  1575.  
  1576.  
  1577.          move.l   bufstart,a4
  1578.  
  1579.          moveq    #1,d2
  1580.  
  1581.  
  1582.  
  1583.          print    mhandle,rstart1
  1584.  
  1585.  
  1586.  
  1587. * Send initial NAK
  1588.  
  1589. xreclp0  bsr      sendnak
  1590.  
  1591.  
  1592.  
  1593. xreclp1a bsr      scanmenu          Has user pressed a key?
  1594.  
  1595.          bne      xrcancel
  1596.  
  1597.  
  1598.  
  1599.          move.w   #20,d6            Wait for block
  1600.  
  1601.          bsr      waitser
  1602.  
  1603.          bpl.s    xrecok1           Keep doing it, if nothing going.
  1604.  
  1605.  
  1606.  
  1607.          print    mhandle,ret1mes
  1608.  
  1609.          bra.s    xreclp0
  1610.  
  1611.  
  1612.  
  1613. xrecok1  cmp.b    #soh,d0
  1614.  
  1615.          beq.s    xrecrcv
  1616.  
  1617.          cmp.b    #eot,d0
  1618.  
  1619.          beq      xreceot
  1620.  
  1621.          cmp.b    #can,d0
  1622.  
  1623.          beq      xrcancel
  1624.  
  1625.  
  1626.  
  1627.          bra.s    xreclp1a
  1628.  
  1629.  
  1630.  
  1631. * Block coming in...
  1632.  
  1633. xrecrcv   bsr      prblock
  1634.  
  1635.  
  1636.  
  1637.          bsr      wait10            Get block
  1638.  
  1639.          bmi      xrslowr
  1640.  
  1641.  
  1642.  
  1643.          cmp.b    d0,d2             Same as current one?
  1644.  
  1645.          bne      xrbadblk
  1646.  
  1647.  
  1648.  
  1649.          bsr      wait10            Get inversed block number
  1650.  
  1651.          bmi      xrslowr
  1652.  
  1653.  
  1654.  
  1655.          not.b    d0
  1656.  
  1657.          cmp.b    d0,d2             Okay?
  1658.  
  1659.          bne      xrbadbl2          Definitely a bad block
  1660.  
  1661.  
  1662.  
  1663. * Get the 128 data bytes
  1664.  
  1665.  
  1666.  
  1667.          move.w   #127,d4           Byte count
  1668.  
  1669.          clr.b    d3                Checksum
  1670.  
  1671.  
  1672.  
  1673. xrecrclp bsr      wait10            Timeout
  1674.  
  1675.          bmi.s    xrecnop3
  1676.  
  1677.          move.b   d0,(a4)+          Store the character
  1678.  
  1679.          add.b    d0,d3             Checksum
  1680.  
  1681.          dbra     d4,xrecrclp       Loop for more
  1682.  
  1683.  
  1684.  
  1685.          bsr      wait10
  1686.  
  1687.          bmi.s    xrcheckm
  1688.  
  1689.          cmp.b    d0,d3             Checksum any good?
  1690.  
  1691.          bne      xrchecks
  1692.  
  1693.  
  1694.  
  1695. * Block was Okay, so increment block counter
  1696.  
  1697.          addq.b   #1,d2             Increment block counter, and continue
  1698.  
  1699.          bsr      sendack
  1700.  
  1701.          bra      xreclp1a
  1702.  
  1703.  
  1704.  
  1705. * A character was missed from inside a block
  1706.  
  1707. xrecnop3 print    mhandle,misschm
  1708.  
  1709.          ext.l    d4
  1710.  
  1711.          add.w    d4,a4
  1712.  
  1713.          sub.w    #127,a4
  1714.  
  1715.  
  1716.  
  1717.          bsr      waitfin
  1718.  
  1719.          bra      xreclp0
  1720.  
  1721.  
  1722.  
  1723. * Missed checksum
  1724.  
  1725. xrcheckm print    mhandle,xchksm2
  1726.  
  1727.          bsr      waitfin
  1728.  
  1729.          bra      xreclp0
  1730.  
  1731.  
  1732.  
  1733. xrchecks sub.l    #128,a4
  1734.  
  1735.          move.l   d0,-(sp)
  1736.  
  1737.          print    mhandle,xchksm
  1738.  
  1739.          move.b   d3,d0
  1740.  
  1741.          and.w    #$ff,d0
  1742.  
  1743.          bsr      bin2decw
  1744.  
  1745.          print    mhandle,xchksm1
  1746.  
  1747.          move.l   (sp)+,d0
  1748.  
  1749.          and.w    #$ff,d0
  1750.  
  1751.          bsr      bin2decw
  1752.  
  1753.          bsr      nlmenu
  1754.  
  1755.  
  1756.  
  1757.          bsr      waitfin
  1758.  
  1759.          bra      xreclp0
  1760.  
  1761.  
  1762.  
  1763. xrslowr  print    mhandle,slowm1
  1764.  
  1765.          bsr      waitfin
  1766.  
  1767.          bra      xreclp0
  1768.  
  1769.  
  1770.  
  1771. xrbadblk addq.b   #1,d0
  1772.  
  1773.          cmp.b    d0,d2
  1774.  
  1775.          beq.s    xrbbb1
  1776.  
  1777.          subq.b   #1,d0
  1778.  
  1779.  
  1780.  
  1781. xrbadbl2 move.l   d0,-(sp)
  1782.  
  1783.          print    mhandle,badblkm
  1784.  
  1785.          move.l   (sp)+,d0
  1786.  
  1787.          and.w    #$ff,d0
  1788.  
  1789.          bsr      bin2decw
  1790.  
  1791.          bsr      nlmenu
  1792.  
  1793.          bsr      waitfin
  1794.  
  1795.          bra      xreclp0
  1796.  
  1797.  
  1798.  
  1799. * If previous block was repeated, then do an ACK to get it up to date
  1800.  
  1801. xrbbb1   bsr      waitfin
  1802.  
  1803.          bsr      sendack
  1804.  
  1805.          print    mhandle,dupmes1
  1806.  
  1807.          bra      xreclp1a
  1808.  
  1809.  
  1810.  
  1811. xreceot  bsr      sendack
  1812.  
  1813.  
  1814.  
  1815.          move.l   a4,bufptr         Update buffer size
  1816.  
  1817.  
  1818.  
  1819.          print    mhandle,xrecm2
  1820.  
  1821.  
  1822.  
  1823. * File downloaded, so now determine the ACCURATE length of file.
  1824.  
  1825.  
  1826.  
  1827.          bsr      rdmenu
  1828.  
  1829.          and.w    #$df,d0
  1830.  
  1831.          cmp.b    #'Y',d0
  1832.  
  1833.          bne      savedown
  1834.  
  1835.  
  1836.  
  1837. * Chop the file here...
  1838.  
  1839.  
  1840.  
  1841.          print    mhandle,xrecm3
  1842.  
  1843.  
  1844.  
  1845.          move.l   bufptr,d0         Current file's length
  1846.  
  1847.          sub.l    bufstart,d0
  1848.  
  1849.          bsr      bin2decl
  1850.  
  1851.  
  1852.  
  1853.          print    mhandle,xrecm4
  1854.  
  1855.  
  1856.  
  1857. * Determine approximate length...
  1858.  
  1859.  
  1860.  
  1861.          move.l   bufptr,a0         Last byte=Null?
  1862.  
  1863.          move.b   -(a0),d1
  1864.  
  1865.  
  1866.  
  1867. detlp1   cmp.b    -(a0),d1          Is the previous byte the same?
  1868.  
  1869.          beq.s    detlp1
  1870.  
  1871.  
  1872.  
  1873.          addq.l   #1,a0             Forward one character again
  1874.  
  1875.  
  1876.  
  1877.          sub.l    bufstart,a0       Turn it into a Length
  1878.  
  1879.          move.l   a0,d0
  1880.  
  1881.  
  1882.  
  1883.          bsr      bin2decl          Print it
  1884.  
  1885.          bsr      nlmenu
  1886.  
  1887.  
  1888.  
  1889. * Perform decimal input value here and change bufptr accordingly!
  1890.  
  1891.  
  1892.  
  1893.          print    mhandle,askchop
  1894.  
  1895.          bsr      getline
  1896.  
  1897.          tst.l    d0
  1898.  
  1899.          beq      savedown
  1900.  
  1901.  
  1902.  
  1903.          lea      inputbuf,a0
  1904.  
  1905.          bsr      dec2bin
  1906.  
  1907.  
  1908.  
  1909.          tst.l    d0
  1910.  
  1911.          beq      savedown
  1912.  
  1913.          bmi      savedown
  1914.  
  1915.  
  1916.  
  1917. * Really ought to check that the CHOP value is within range here!!
  1918.  
  1919.  
  1920.  
  1921.          add.l    bufstart,d0
  1922.  
  1923.          move.l   d0,bufptr
  1924.  
  1925.  
  1926.  
  1927. savedown bsr      savebuf
  1928.  
  1929.          bra      menuagn
  1930.  
  1931.  
  1932.  
  1933. * Wait for ONE total second of nothingness!
  1934.  
  1935.  
  1936.  
  1937. waitfin  move.w   #2,d6
  1938.  
  1939.          bsr      waitser
  1940.  
  1941.          bpl.s    waitfin
  1942.  
  1943.          rts
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949. * Print the current block number
  1950.  
  1951. prblock  movem.l  d0-d7/a0-a6,-(sp)
  1952.  
  1953.          print    mhandle,pblokm
  1954.  
  1955.          clr.l    d0
  1956.  
  1957.          move.b   d2,d0
  1958.  
  1959.          bsr      bin2decw
  1960.  
  1961.          move.b   #32,d0
  1962.  
  1963.          bsr      wrmenu
  1964.  
  1965.          bsr      wrmenu
  1966.  
  1967.          bsr      wrmenu
  1968.  
  1969.          move.b   #13,d0
  1970.  
  1971.          bsr      wrmenu
  1972.  
  1973.          movem.l  (sp)+,d0-d7/a0-a6
  1974.  
  1975.          rts
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981. * Waits ten seconds for a character then gives up
  1982.  
  1983.  
  1984.  
  1985. wait10   move.w   #10,d6
  1986.  
  1987.  
  1988.  
  1989. * Scan for a character with wait for d6 number of seconds
  1990.  
  1991.  
  1992.  
  1993. waitser  bsr      scanser
  1994.  
  1995.          bpl.s    retwait1
  1996.  
  1997.  
  1998.  
  1999.          subq.w   #1,d6
  2000.  
  2001. waitser1 move.w   #17000,d7
  2002.  
  2003. waitser2 bsr      scanser
  2004.  
  2005.          bpl.s    retwait1
  2006.  
  2007.          dbra     d7,waitser2
  2008.  
  2009.          dbra     d6,waitser1
  2010.  
  2011.          moveq    #-1,d0         Necessary?
  2012.  
  2013. retwait1 tst.l    d0
  2014.  
  2015.          rts
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029. * Terminate this program and return to CLI
  2030.  
  2031.  
  2032.  
  2033. terminate
  2034.  
  2035.          lea      read_reply,a1  Remove the Reply Port
  2036.  
  2037.          move.l   sysbase,a6     Exec Lib Ptr
  2038.  
  2039.          jsr      _LVORemPort(a6)
  2040.  
  2041.  
  2042.  
  2043.          lea      write_reply,a1 Remove this one too
  2044.  
  2045.          jsr      _LVORemPort(a6)
  2046.  
  2047.  
  2048.  
  2049.          lea      nwriterep,a1   Remove Narrator port
  2050.  
  2051.          jsr      _LVORemPort(a6)
  2052.  
  2053.  
  2054.  
  2055.          lea      readreq,a1     Close the Serial Device
  2056.  
  2057.          jsr      _LVOCloseDevice(a6)
  2058.  
  2059.  
  2060.  
  2061.          lea      writereq,a1    Again
  2062.  
  2063.          jsr      _LVOCloseDevice(a6)
  2064.  
  2065.  
  2066.  
  2067.          lea      talkio,a1      Narrator Device
  2068.  
  2069.          jsr      _LVOCloseDevice(a6)
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.          move.l   chandle,d1     Close Console window for final time
  2076.  
  2077.          move.l   dosbase,a6
  2078.  
  2079.          jsr      _LVOClose(a6)
  2080.  
  2081.  
  2082.  
  2083.          move.l   tranbase,a1    Close the translator library
  2084.  
  2085.          move.l   sysbase,a6
  2086.  
  2087.          jsr      _LVOCloseLibrary(a6)
  2088.  
  2089.  
  2090.  
  2091.          move.l   dosbase,a1     Close the DOS library
  2092.  
  2093.          jsr      _LVOCloseLibrary(a6)
  2094.  
  2095.  
  2096.  
  2097.          moveq    #0,d1          Return Code=Good
  2098.  
  2099.          move.l   d1,d0
  2100.  
  2101.  
  2102.  
  2103. exitprog move.l   saveSP,sp      Restore Old Stack Pointer
  2104.  
  2105.          rts                     Yea, a JMP would have sufficed!
  2106.  
  2107.  
  2108.  
  2109. * Dos command to open a file
  2110.  
  2111.  
  2112.  
  2113. openfile move.l   a1,d1             Wants it in Data register (weird!)
  2114.  
  2115.          move.l   #MODE_OLDFILE,d2  Signal not to create a new file
  2116.  
  2117.          move.l   dosbase,a6        Dos lib
  2118.  
  2119.          jsr      _LVOOpen(a6)      Open the file
  2120.  
  2121.          tst.l    d0                An Error perhaps?
  2122.  
  2123.          rts                        File's handle in d0
  2124.  
  2125.  
  2126.  
  2127. * Opens a file for writing!
  2128.  
  2129. openwrite
  2130.  
  2131.          move.l   a1,d1
  2132.  
  2133.          move.l   #MODE_NEWFILE,d2
  2134.  
  2135.          move.l   dosbase,a6
  2136.  
  2137.          jsr      _LVOOpen(a6)
  2138.  
  2139.          tst.l    d0
  2140.  
  2141.          rts
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147. * Signal an error because something didn't Open properly!
  2148.  
  2149.  
  2150.  
  2151. *openerr move.l   chandle,d1     Close Console window for final time
  2152.  
  2153.          move.l   dosbase,a6
  2154.  
  2155.          jsr      _LVOClose(a6)
  2156.  
  2157. openerr
  2158.  
  2159.          move.l   dosbase,a1     Close the DOS library
  2160.  
  2161.          move.l   sysbase,a6
  2162.  
  2163.          jsr      _LVOCloseLibrary(a6)
  2164.  
  2165.  
  2166.  
  2167.          moveq    #-1,d1         Return code = BAD!
  2168.  
  2169.          move.l   d1,d0
  2170.  
  2171.  
  2172.  
  2173.          bra      exitprog
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179. * Prints the message pointed to by a0, (Null terminated).
  2180.  
  2181.  
  2182.  
  2183. message  movem.l  d0-d3,-(sp)
  2184.  
  2185.          move.l   a0,d2                Start of message
  2186.  
  2187.          clr.l    d3                   Length is zero for the moment
  2188.  
  2189. message1 tst.b    (a0)+                End of message?
  2190.  
  2191.          beq.s    message2             Length known, go print it now!
  2192.  
  2193.          addq.l   #1,d3                Increment Length
  2194.  
  2195.          bra.s    message1             Back for more characters
  2196.  
  2197.  
  2198.  
  2199. * Ready to print message now: d1=dest handle, d2=ptr to text, d3=length.
  2200.  
  2201.  
  2202.  
  2203. message2 move.l   dosbase,a6           Library ptr
  2204.  
  2205.          jsr      _LVOWrite(a6)        Write the text to the console window
  2206.  
  2207.          movem.l  (sp)+,d0-d3
  2208.  
  2209.          rts
  2210.  
  2211.  
  2212.  
  2213. wrmenu   movem.l  d0-d7/a0-a6,-(sp)
  2214.  
  2215.          move.l   mhandle,d1
  2216.  
  2217.          bra.s    chrout2
  2218.  
  2219.  
  2220.  
  2221. * Write character in d0 to Console Window
  2222.  
  2223.  
  2224.  
  2225. wrchar   movem.l  d0-d7/a0-a6,-(sp)    Save World!  (MOVEM overkill!??)
  2226.  
  2227.          move.l   chandle,d1           handle of Console window
  2228.  
  2229.  
  2230.  
  2231. chrout2  lea      cbuff,a1             Point to the character buffer
  2232.  
  2233.          move.b   d0,(a1)              Put character in buffer
  2234.  
  2235.          move.l   a1,d2                Weird data register usage
  2236.  
  2237.          move.l   #1,d3                Length
  2238.  
  2239.          move.l   dosbase,a6           Library ptr
  2240.  
  2241.          jsr      _LVOWrite(a6)        Write the text to the console window
  2242.  
  2243.  
  2244.  
  2245.          movem.l  (sp)+,d0-d7/a0-a6    Restore World
  2246.  
  2247.          rts
  2248.  
  2249.  
  2250.  
  2251. * Shortened special-case Serial characters
  2252.  
  2253.  
  2254.  
  2255. sendxon  move.b   #xon,d0           Send an Xon to resume data flow
  2256.  
  2257.          bra.s    sendser
  2258.  
  2259.  
  2260.  
  2261. sendxoff move.b   #xoff,d0          Send an Xoff to freeze data flow
  2262.  
  2263.          bra.s    sendser
  2264.  
  2265.  
  2266.  
  2267. sendack  move.b   #ack,d0           Send an ACK for acknowledgement of block
  2268.  
  2269.          bra.s    sendser
  2270.  
  2271.  
  2272.  
  2273. sendnak  move.b   #nak,d0           Send a NAK to indicate error of block
  2274.  
  2275.          bra.s    sendser
  2276.  
  2277.  
  2278.  
  2279. newline  move.b   #cr,d0            Print a NEWLINE
  2280.  
  2281.          bsr.s    wrchar
  2282.  
  2283.          move.b   #lf,d0            carriage return + line feed
  2284.  
  2285.          bra.s    wrchar
  2286.  
  2287.  
  2288.  
  2289. dospace  move.b   #space,d0         Print a Space
  2290.  
  2291.          bra.s    wrchar
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297. * Serial Character Input
  2298.  
  2299. serin    movem.l  d1-d7/a0-a6,-(sp) Save World!
  2300.  
  2301.  
  2302.  
  2303. * Do a WaitIO to get the char, and followed by a SendIO to initiate the
  2304.  
  2305. * next read!
  2306.  
  2307.  
  2308.  
  2309.          lea      readreq,a1           Ptr to Request Block
  2310.  
  2311.          move.l   sysbase,a6           Exec lib ptr
  2312.  
  2313.          jsr      _LVOWaitIO(a6)
  2314.  
  2315.  
  2316.  
  2317.          clr.l    d0
  2318.  
  2319.          move.b   bufin,d0             The byte returned
  2320.  
  2321.          move.l   d0,-(sp)
  2322.  
  2323.  
  2324.  
  2325.          lea      readreq,a1           Request block
  2326.  
  2327.          move.l   #1,IO_LENGTH(a1)
  2328.  
  2329.          jsr      _LVOSendIO(a6)       Initiate the NEXT read
  2330.  
  2331.  
  2332.  
  2333.          move.l   (sp)+,d0
  2334.  
  2335.  
  2336.  
  2337.          movem.l  (sp)+,d1-d7/a0-a6    Restore World
  2338.  
  2339.          tst.l    d0                   Always Positive, so set PL flag
  2340.  
  2341.          rts
  2342.  
  2343.  
  2344.  
  2345. sendser  movem.l  d0-d7/a0-a6,-(sp)    Save World
  2346.  
  2347.  
  2348.  
  2349.          lea      writereq,a1          Ptr to Write Request block
  2350.  
  2351.          move.w   #CMD_WRITE,IO_COMMAND(a1)
  2352.  
  2353.          move.l   #1,IO_LENGTH(a1)     One byte
  2354.  
  2355.          move.l   #bufout,IO_DATA(a1)  Buffer address
  2356.  
  2357.  
  2358.  
  2359.          move.l   sysbase,a6           Exec Lib Ptr
  2360.  
  2361.          move.b   d0,bufout            Put byte and send it
  2362.  
  2363.  
  2364.  
  2365.          jsr      _LVODoIO(a6)         Send Byte
  2366.  
  2367.  
  2368.  
  2369.          movem.l  (sp)+,d0-d7/a0-a6    Restore World
  2370.  
  2371.          rts
  2372.  
  2373.  
  2374.  
  2375. * Read character into d0 from Console Window
  2376.  
  2377.  
  2378.  
  2379. rdchar   movem.l  d1-d7/a0-a6,-(sp)    Save World!
  2380.  
  2381.          move.l   chandle,d1           handle of Console window
  2382.  
  2383.          bra.s    chrin2
  2384.  
  2385.  
  2386.  
  2387. rdmenu   movem.l  d1-d7/a0-a6,-(sp)    Save World!
  2388.  
  2389.          move.l   mhandle,d1           Handle of Menu window
  2390.  
  2391.  
  2392.  
  2393. chrin2   lea      cbuff,a1
  2394.  
  2395.          move.l   a1,d2                Point to the character
  2396.  
  2397.          move.l   #1,d3                Length
  2398.  
  2399.          move.l   dosbase,a6           Library ptr
  2400.  
  2401.          jsr      _LVORead(a6)         Write the text to the console window
  2402.  
  2403.          clr.l    d0                   Prepare for receipt of a Char
  2404.  
  2405.          move.b   cbuff,d0             Character returned in d0
  2406.  
  2407.          movem.l  (sp)+,d1-d7/a0-a6    Restore World
  2408.  
  2409.          rts
  2410.  
  2411.  
  2412.  
  2413. * Scans for a key from the Keyboard, if nothing there, sets MINUS flag!
  2414.  
  2415. * Otherwise, character in d0
  2416.  
  2417.  
  2418.  
  2419. scanmenu movem.l  d1-d2,-(sp)
  2420.  
  2421.  
  2422.  
  2423.          move.l   mhandle,d1
  2424.  
  2425.          move.l   #keytime,d2
  2426.  
  2427.          move.l   dosbase,a6
  2428.  
  2429.          jsr      _LVOWaitForChar(a6)
  2430.  
  2431.  
  2432.  
  2433.          movem.l  (sp)+,d1-d2
  2434.  
  2435.  
  2436.  
  2437.          tst.l    d0
  2438.  
  2439.          beq.s    nokey1
  2440.  
  2441.  
  2442.  
  2443.          bra      rdmenu
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453. scankey  move.l   chandle,d1           Console Handle
  2454.  
  2455.          move.l   #keytime,d2          Timeout
  2456.  
  2457.          move.l   dosbase,a6           Dos library
  2458.  
  2459.          jsr      _LVOWaitForChar(a6)  Anything waiting for us?
  2460.  
  2461.          tst.l    d0                   False=0
  2462.  
  2463.          beq.s    nokey1               Nothing there!
  2464.  
  2465.  
  2466.  
  2467.          bra.s    rdchar               Proceed further to Get it
  2468.  
  2469.  
  2470.  
  2471. nokey1   rts
  2472.  
  2473.  
  2474.  
  2475. scanser  lea      readreq,a1           Check to see if a character is there
  2476.  
  2477.          move.l   sysbase,a6           exec lib ptr
  2478.  
  2479.          jsr      _LVOCheckIO(a6)      Anything there?
  2480.  
  2481.          tst.l    d0                   Z=nothing
  2482.  
  2483.          bne      serin
  2484.  
  2485.  
  2486.  
  2487.          moveq    #-1,d0
  2488.  
  2489.          rts
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495. * Text to speech of serial input
  2496.  
  2497.  
  2498.  
  2499. squalk   tst.b    squalking         Am I enabled?
  2500.  
  2501.          bne      endsqualk
  2502.  
  2503.  
  2504.  
  2505. * Send an XOFF to prevent host from sending anymore
  2506.  
  2507.          bsr      sendxoff
  2508.  
  2509.  
  2510.  
  2511. * Clear output buffer before use
  2512.  
  2513.  
  2514.  
  2515.          move.w   #127,d0
  2516.  
  2517.          lea      outtext,a0
  2518.  
  2519. sqclrlp  clr.l    (a0)+
  2520.  
  2521.          dbra     d0,sqclrlp
  2522.  
  2523.  
  2524.  
  2525. * Use Translator to convert input text into output phonemes
  2526.  
  2527.  
  2528.  
  2529.          lea      intext,a0
  2530.  
  2531.          move.l   lengthin,d0
  2532.  
  2533.  
  2534.  
  2535.          lea      outtext,a1
  2536.  
  2537.          move.l   #512,d1             Fixed length output buffer
  2538.  
  2539.  
  2540.  
  2541.          move.l   tranbase,a6
  2542.  
  2543.          jsr      _LVOTranslate(a6)
  2544.  
  2545.  
  2546.  
  2547. * Use narrator to speak the phoneme text
  2548.  
  2549.  
  2550.  
  2551.          lea      talkio,a1            Narrator Request block
  2552.  
  2553.          move.w   #CMD_WRITE,IO_COMMAND(a1)
  2554.  
  2555.          move.l   #512,IO_LENGTH(a1)  Fixed length!
  2556.  
  2557.          move.l   #outtext,IO_DATA(a1)
  2558.  
  2559.  
  2560.  
  2561.          move.l   sysbase,a6
  2562.  
  2563.          jsr      _LVODoIO(a6)         Should be SendIO perhaps!?
  2564.  
  2565.  
  2566.  
  2567.          bsr      sendxon              Allow HOST to continue sending
  2568.  
  2569.  
  2570.  
  2571. endsqualk
  2572.  
  2573.          clr.l    lengthin             Reset the text buffers
  2574.  
  2575.          move.l   #intext,textptr
  2576.  
  2577.  
  2578.  
  2579.          rts
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585. * Power of Ten table! (for binary/ascii routines!)
  2586.  
  2587.  
  2588.  
  2589. tentable dc.l     1
  2590.  
  2591.          dc.l     10
  2592.  
  2593.          dc.l     100
  2594.  
  2595.          dc.l     1000
  2596.  
  2597.          dc.l     10000
  2598.  
  2599. tenbckw  dc.l     100000
  2600.  
  2601.          dc.l     1000000
  2602.  
  2603.          dc.l     10000000
  2604.  
  2605.          dc.l     100000000
  2606.  
  2607. tenback  dc.l     1000000000
  2608.  
  2609.  
  2610.  
  2611.  
  2612.  
  2613.  
  2614.  
  2615. * Print a number that is contained in binary in d0
  2616.  
  2617. bin2decw movem.l  d0-d7/a0,-(sp)
  2618.  
  2619.          clr.w    d4
  2620.  
  2621.          lea      tenbckw(pc),a0
  2622.  
  2623.          moveq    #4,d3
  2624.  
  2625.          tst.w    d0
  2626.  
  2627.          beq.s    binzero
  2628.  
  2629.          bpl.s    bindecl
  2630.  
  2631.          neg.w    d0
  2632.  
  2633.          bra.s    bindecw
  2634.  
  2635.  
  2636.  
  2637. * Print up a Long Word in binary
  2638.  
  2639. bin2decl movem.l  d0-d7/a0,-(sp)
  2640.  
  2641.          clr.w    d4
  2642.  
  2643.          lea      tenback(pc),a0
  2644.  
  2645.          moveq    #8,d3
  2646.  
  2647.          tst.l    d0
  2648.  
  2649.          beq.s    binzero
  2650.  
  2651.          bpl.s    bindecl
  2652.  
  2653.          neg.l    d0
  2654.  
  2655.  
  2656.  
  2657. bindecw  move.b   #'-',d1
  2658.  
  2659.          bsr      wrchd1
  2660.  
  2661.  
  2662.  
  2663. bindecl  move.l   -(a0),d1
  2664.  
  2665.          clr.w    d2
  2666.  
  2667.  
  2668.  
  2669. bindec1  sub.l    d1,d0
  2670.  
  2671.          bmi.s    bindec2
  2672.  
  2673.          addq.w   #1,d2
  2674.  
  2675.          bra.s    bindec1
  2676.  
  2677.  
  2678.  
  2679. bindec2  add.l    d1,d0
  2680.  
  2681.  
  2682.  
  2683.          tst.w    d2
  2684.  
  2685.          bne.s    bindecz
  2686.  
  2687.          tst.w    d4
  2688.  
  2689.          beq.s    bindec3
  2690.  
  2691.  
  2692.  
  2693. bindecz  move.w   d2,d1
  2694.  
  2695.          add.w    #$30,d1
  2696.  
  2697.          bsr      wrchd1
  2698.  
  2699.          moveq    #1,d4
  2700.  
  2701.  
  2702.  
  2703. bindec3  dbra     d3,bindecl
  2704.  
  2705.          movem.l  (sp)+,d0-d7/a0
  2706.  
  2707.          rts
  2708.  
  2709.  
  2710.  
  2711. * Special Case of Zero
  2712.  
  2713.  
  2714.  
  2715. binzero  move.b   #'0',d0
  2716.  
  2717.          bsr      wrmenu
  2718.  
  2719.          movem.l  (sp)+,d0-d7/a0
  2720.  
  2721.          rts
  2722.  
  2723.  
  2724.  
  2725. * Weird version of WRCHAR that uses d1 instead of d0
  2726.  
  2727.  
  2728.  
  2729. wrchd1   move.l   d0,-(sp)
  2730.  
  2731.          move.l   d1,d0
  2732.  
  2733.          bsr      wrmenu
  2734.  
  2735.          move.l   (sp)+,d0
  2736.  
  2737.          rts
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745. * Decimal Ascii to Binary routine...
  2746.  
  2747.  
  2748.  
  2749. dec2bin  movem.l  d1-d5/a1,-(sp)
  2750.  
  2751.  
  2752.  
  2753.          clr.l    d0
  2754.  
  2755.          clr.l    d1
  2756.  
  2757.          clr.w    d4
  2758.  
  2759.          lea      tentable(pc),a1
  2760.  
  2761.  
  2762.  
  2763.          move.b   (a0)+,d1
  2764.  
  2765.          cmp.b    #'-',d1
  2766.  
  2767.          seq      d5
  2768.  
  2769.          beq.s    dnumlp
  2770.  
  2771.          cmp.b    #'+',d1
  2772.  
  2773.          bne.s    dnumlp1
  2774.  
  2775.  
  2776.  
  2777. * Main primary loop to find the last digit
  2778.  
  2779.  
  2780.  
  2781. dnumlp   move.b   (a0)+,d1
  2782.  
  2783. dnumlp1  cmp.b    #'0',d1
  2784.  
  2785.          blt.s    atend0
  2786.  
  2787.          cmp.b    #'9',d1
  2788.  
  2789.          bgt.s    atend0
  2790.  
  2791.          addq.w   #1,d4
  2792.  
  2793.          bra.s    dnumlp
  2794.  
  2795.  
  2796.  
  2797. atend0   subq.l   #1,a0
  2798.  
  2799.          subq.w   #1,d4
  2800.  
  2801.          move.l   a0,-(sp)
  2802.  
  2803.  
  2804.  
  2805. * Fall thru into secondary loop to evaluate digits
  2806.  
  2807.  
  2808.  
  2809. atend1   move.b   -(a0),d1
  2810.  
  2811.          move.l   (a1)+,d2
  2812.  
  2813.          and.w    #15,d1
  2814.  
  2815.          subq.w   #1,d1
  2816.  
  2817.          bmi.s    atend3
  2818.  
  2819.          clr.l    d3
  2820.  
  2821.  
  2822.  
  2823. atend2   add.l    d2,d3
  2824.  
  2825.          dbra     d1,atend2
  2826.  
  2827.          add.l    d3,d0
  2828.  
  2829.  
  2830.  
  2831. atend3   dbra     d4,atend1
  2832.  
  2833.  
  2834.  
  2835. * Finished conversion, so check sign here...
  2836.  
  2837.  
  2838.  
  2839.          tst.b    d5
  2840.  
  2841.          beq.s    fincon2
  2842.  
  2843.          neg.l    d0
  2844.  
  2845. fincon2  move.l   (sp)+,a0
  2846.  
  2847.          movem.l   (sp)+,d1-d5/a1
  2848.  
  2849.          rts
  2850.  
  2851.  
  2852.  
  2853.  
  2854.  
  2855.  
  2856.  
  2857. * Set the baud rate
  2858.  
  2859.  
  2860.  
  2861. setbaud  tst.l    baud
  2862.  
  2863.          beq      setbaud2
  2864.  
  2865.  
  2866.  
  2867.          print    mhandle,baudold
  2868.  
  2869.          move.l   baud,d0
  2870.  
  2871.          bsr      bin2decl
  2872.  
  2873.          bsr      nlmenu
  2874.  
  2875. setbaud2 bsr      nlmenu
  2876.  
  2877.  
  2878.  
  2879.          print    mhandle,baudmes
  2880.  
  2881.          bsr      getline
  2882.  
  2883.          tst.l    d0
  2884.  
  2885.          beq      menuagn
  2886.  
  2887.  
  2888.  
  2889.          lea      inputbuf,a0
  2890.  
  2891.          bsr      dec2bin
  2892.  
  2893.  
  2894.  
  2895.          move.l   d0,-(sp)
  2896.  
  2897.          bsr      nlmenu
  2898.  
  2899.          bsr      nlmenu
  2900.  
  2901.          move.l   (sp)+,d0
  2902.  
  2903.  
  2904.  
  2905.          tst.l    d0
  2906.  
  2907.          beq      menuagn
  2908.  
  2909.          bmi      menuagn
  2910.  
  2911.  
  2912.  
  2913.          move.l   d0,baud
  2914.  
  2915.  
  2916.  
  2917.          bsr      abortser
  2918.  
  2919.  
  2920.  
  2921. * Initialise the Serial Port to the selected baud rate.
  2922.  
  2923.  
  2924.  
  2925.          lea      readreq,a1              Point to write request block
  2926.  
  2927.          move.l   baud,IO_BAUD(a1)        Baud Rate
  2928.  
  2929.          move.b   #myflags,IO_SERFLAGS(a1)
  2930.  
  2931.          move.w   #SDCMD_SETPARAMS,IO_COMMAND(a1)
  2932.  
  2933.  
  2934.  
  2935.          move.l   sysbase,a6
  2936.  
  2937.          jsr      _LVODoIO(a6)            Send it!
  2938.  
  2939.  
  2940.  
  2941.          bsr      initser
  2942.  
  2943.  
  2944.  
  2945.          bra      menuagn
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953. * Initiate the Serial Receive to get a character
  2954.  
  2955.  
  2956.  
  2957. initser  lea      readreq,a1        I request block
  2958.  
  2959.          move.l   #1,IO_LENGTH(a1)  How many characters
  2960.  
  2961.          move.w   #CMD_READ,IO_COMMAND(a1)
  2962.  
  2963.          move.l   #bufin,IO_DATA(a1)
  2964.  
  2965.  
  2966.  
  2967.          move.l   sysbase,a6
  2968.  
  2969.          jmp      _LVOSendIO(a6)
  2970.  
  2971.  
  2972.  
  2973. abortser lea      readreq,a1
  2974.  
  2975.          move.l   sysbase,a6
  2976.  
  2977.          jmp      _LVOAbortIO(a6)
  2978.  
  2979.  
  2980.  
  2981.  
  2982.  
  2983.  
  2984.  
  2985.  
  2986.  
  2987. * Library Definitions :
  2988.  
  2989.  
  2990.  
  2991. thedos   DOSNAME
  2992.  
  2993.          cnop     0,2
  2994.  
  2995.  
  2996.  
  2997. thetrans dc.b     'translator.library',0               * Where's the Macro!??
  2998.  
  2999.          cnop     0,2
  3000.  
  3001.  
  3002.  
  3003. * Device Definitions
  3004.  
  3005.  
  3006.  
  3007. serdevice SERIALNAME
  3008.  
  3009.          cnop     0,2
  3010.  
  3011.  
  3012.  
  3013. nardevice dc.b    'narrator.device',0
  3014.  
  3015.          cnop     0,2
  3016.  
  3017.  
  3018.  
  3019. amaps    dc.b     3,5,10,12            Audio Channel Maps
  3020.  
  3021.          cnop     0,2
  3022.  
  3023.  
  3024.  
  3025. * Textual Definitions
  3026.  
  3027.  
  3028.  
  3029. conname  dc.b     'RAW:0/0/640/200/ArgoTerm 0.20',0
  3030.  
  3031.          cnop     0,2
  3032.  
  3033. sername  dc.b     'SER:',0
  3034.  
  3035.          cnop     0,2
  3036.  
  3037. welcome  dc.b     'ArgoTerm, by Jez San, (c)1986 Argonaut Software Ltd.,'
  3038.  
  3039.          dc.b     ' London, England.',13,10
  3040.  
  3041.          dc.b     'Freeware: No profit must be made from the distribution'
  3042.  
  3043.          dc.b     ' of this program.',13,10
  3044.  
  3045.          dc.b     '[Use the AmigaDOS STACK command to allow a larger Capture '
  3046.  
  3047.          dc.b     'Buffer]',13,10,10
  3048.  
  3049.          dc.b     'Press the HELP key for the Command Menu.',13,10,10,0
  3050.  
  3051.          cnop     0,2
  3052.  
  3053. menutext dc.b     'You may choose from the following options :',13,10,10
  3054.  
  3055.          dc.b     'B - Configure the transmission speed (Baud Rate),',13,10
  3056.  
  3057.          dc.b     'C - Clear (wipe) the Capture Buffer,',13,10
  3058.  
  3059.          dc.b     'D - Download text into the Capture Buffer,',13,10
  3060.  
  3061.          dc.b     'E - Local Echo mode (Half Duplex) on/off,',13,10
  3062.  
  3063.          dc.b     'L - Load a disk file into the Buffer,',13,10
  3064.  
  3065.          dc.b     'Q - Quit this program; terminate session,',13,10
  3066.  
  3067.          dc.b     'T - Turn On/Off the Squalk Mode (narrator),',13,10
  3068.  
  3069.          dc.b     'U - Upload the contents of the Capture Buffer,',13,10
  3070.  
  3071.          dc.b     'X - Xmodem file transmission (aka MODEM7).',13,10,10
  3072.  
  3073.          dc.b     'There are ',0
  3074.  
  3075.          cnop     0,2
  3076.  
  3077. infmess1 dc.b     ' out of ',0
  3078.  
  3079.          cnop     0,2
  3080.  
  3081. infmess2 dc.b     ' characters in the Capture Buffer.',13,10,10
  3082.  
  3083.          dc.b     'Please select one of the above options,',13,10
  3084.  
  3085.          dc.b     'or ESC to return to the terminal session.',13,10,0
  3086.  
  3087.          cnop     0,2
  3088.  
  3089. down1m   dc.b     13,10,'Capturing text now, select DOWNLOAD again to '
  3090.  
  3091.          dc.b     ' finish and store.',13,10,10,0
  3092.  
  3093.          cnop     0,2
  3094.  
  3095. down2m   dc.b     13,10,'File saved, Download is complete.',13,10,10,0
  3096.  
  3097.          cnop     0,2
  3098.  
  3099. upld1m   dc.b     'Text will be upload when you return to the Terminal.'
  3100.  
  3101.          dc.b     13,10,10,0
  3102.  
  3103.          cnop     0,2
  3104.  
  3105. upld2m   dc.b     'Hmmm.. You ARE already uploading!!',13,10,10,0
  3106.  
  3107.          cnop     0,2
  3108.  
  3109. nowset2m dc.b     'Configured for: ',0
  3110.  
  3111.          cnop     0,2
  3112.  
  3113. fullm    dc.b     'Full Duplex.',13,10,10,0
  3114.  
  3115.          cnop     0,2
  3116.  
  3117. halfm    dc.b     'Half Duplex.',13,10,10,0
  3118.  
  3119.          cnop     0,2
  3120.  
  3121. ioerrmes dc.b     'Serial I/O Error!',13,10,0
  3122.  
  3123.          cnop     0,2
  3124.  
  3125. yessqm   dc.b     13,10,'Squalk Mode On!',13,10,10,0
  3126.  
  3127.          cnop     0,2
  3128.  
  3129. notsqm   dc.b     13,10,'Squalk Mode Off!',13,10,10,0
  3130.  
  3131.          cnop     0,2
  3132.  
  3133. warnmes  dc.b     13,10,10,'Memory Full!!  Please SAVE the Buffer!',13,10,10
  3134.  
  3135.          dc.b     'Press any key to enter the menu.',13,10,10,0
  3136.  
  3137.          cnop     0,2
  3138.  
  3139. savemes  dc.b     'Save Buffer.',13,10,10,0
  3140.  
  3141.          cnop     0,2
  3142.  
  3143. filemes  dc.b     13,10,'Please enter the filename : ',0
  3144.  
  3145.          cnop     0,2
  3146.  
  3147. bloadmes dc.b     13,10,10,'File not loaded!',13,10,10,0
  3148.  
  3149.          cnop     0,2
  3150.  
  3151. bsavemes dc.b     13,10,10,'File not saved!',13,10,10,0
  3152.  
  3153.          cnop     0,2
  3154.  
  3155. xmes1    dc.b     13,10,10,'Xmodem transfer; <U>pload or <D>ownload ?',13,10,0
  3156.  
  3157.          cnop     0,2
  3158.  
  3159. upmes1   dc.b     13,10,'Waiting for receiver to start the transfer...',13,10,0
  3160.  
  3161.          cnop     0,2
  3162.  
  3163. uperr1   dc.b     13,10,'Receiver not happy, retrying...',13,10,0
  3164.  
  3165.          cnop     0,2
  3166.  
  3167. updun1   dc.b     13,10,'File transferred safely.',13,10,0
  3168.  
  3169.          cnop     0,2
  3170.  
  3171. cancmes  dc.b     13,10,'For some reason, the transfer has been cancelled.'
  3172.  
  3173.          dc.b     13,10,'Bearing in mind that this could have been line'
  3174.  
  3175.          dc.b     13,10,'noise, you may press <Y> to continue, or any other'
  3176.  
  3177.          dc.b     13,10,'key to abort this transfer.',13,10,10,0
  3178.  
  3179.          cnop     0,2
  3180.  
  3181. rstart1  dc.b     13,10,10,'Initiating the transfer (my NAK has been sent!)'
  3182.  
  3183.          dc.b     13,10,0
  3184.  
  3185.          cnop     0,2
  3186.  
  3187. ret1mes  dc.b     13,10,'No response, re-requesting the block.',13,10,0
  3188.  
  3189.          cnop     0,2
  3190.  
  3191. xrecm2   dc.b     13,10,'File downloaded successfully.',13,10,10
  3192.  
  3193.          dc.b     'Due to XMODEM inaccuracies, the length of the file has '
  3194.  
  3195.          dc.b     'been rounded up to',13,10
  3196.  
  3197.          dc.b     'the next nearest block.  Do you wish to CHOP the '
  3198.  
  3199.          dc.b     'file to the correct length?',0
  3200.  
  3201.          cnop     0,2
  3202.  
  3203. xrecm3   dc.b     13,10,10,'The length of the file is currently : ',0
  3204.  
  3205.          cnop     0,2
  3206.  
  3207. xrecm4   dc.b     13,10,10,'My intelligent estimate of the file length is : ',0
  3208.  
  3209.          cnop     0,2
  3210.  
  3211. askchop  dc.b     13,10,10,'You may either use my Estimate, or your own '
  3212.  
  3213.          dc.b     'figures, or alternatively',13,10
  3214.  
  3215.          dc.b     'you may press RETURN to leave the file at its current '
  3216.  
  3217.          dc.b     'length.'
  3218.  
  3219.          dc.b     13,10,10,'What length would you like this file to be ? ',0
  3220.  
  3221.          cnop     0,2
  3222.  
  3223. slowm1   dc.b     13,10,'Slow (or not enough) response.',13,10,0
  3224.  
  3225.          cnop     0,2
  3226.  
  3227. badblkm  dc.b     13,10,'Bad block received was : ',0
  3228.  
  3229.          cnop     0,2
  3230.  
  3231. dupmes1  dc.b     13,10,'A duplicate block has been received.',13,10,0
  3232.  
  3233.          cnop     0,2
  3234.  
  3235. misschm  dc.b     13,10,'Missed a character in the block.',13,10,0
  3236.  
  3237.          cnop     0,2
  3238.  
  3239. xchksm   dc.b     13,10,'Checksum Error in the block, should have been ',0
  3240.  
  3241.          cnop     0,2
  3242.  
  3243. xchksm1  dc.b     ' but was ',0
  3244.  
  3245.          cnop     0,2
  3246.  
  3247. xchksm2  dc.b     13,10,'Checksum was missing from the block.',13,10,0
  3248.  
  3249.          cnop     0,2
  3250.  
  3251. exitmess dc.b     13,10,10,'To exit: hit a key, and wait patiently!',13,10,10
  3252.  
  3253.          dc.b     0
  3254.  
  3255.          cnop     0,2
  3256.  
  3257. pblokm   dc.b     'Current block : ',0
  3258.  
  3259.          cnop     0,2
  3260.  
  3261. baudmes  dc.b     13,10,10,'Please enter the baud rate, or RETURN to leave '
  3262.  
  3263.          dc.b     'it the same ? ',0
  3264.  
  3265.          cnop     0,2
  3266.  
  3267. baudold  dc.b     13,10,'Current baudrate is : ',0
  3268.  
  3269.          cnop     0,2
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.          section     vars,bss
  3276.  
  3277.  
  3278.  
  3279. startbss
  3280.  
  3281.  
  3282.  
  3283.             cnop     0,4
  3284.  
  3285.  
  3286.  
  3287. readreq     ds.l     20    Serial Input Request area
  3288.  
  3289. writereq    ds.l     20    Serial Output Request area
  3290.  
  3291. narread     ds.l     20    Narrator Input
  3292.  
  3293. talkio      ds.l     20    Narrator Output
  3294.  
  3295. read_reply  ds.l     8     Read Reply Port
  3296.  
  3297. write_reply ds.l     8     Write Reply port
  3298.  
  3299. nwriterep   ds.l     8     Narrator write reply
  3300.  
  3301. inputbuf    ds.l     20    Space for some keyboard text!
  3302.  
  3303. filehead    ds.l     8     Space for the filename
  3304.  
  3305.  
  3306.  
  3307. intext      ds.l     64    Input text buffer is 256 bytes
  3308.  
  3309. outtext     ds.l     128   Output phonetic text (512 bytes worth of phonemes!)
  3310.  
  3311.  
  3312.  
  3313.  
  3314.  
  3315. * Long Words
  3316.  
  3317.  
  3318.  
  3319. saveSP   ds.l     1     Initial Stack Pointer
  3320.  
  3321. dosbase  ds.l     1     Base of Dos library
  3322.  
  3323. tranbase ds.l     1     Base of Translator
  3324.  
  3325. chandle  ds.l     1     Handle for Console window
  3326.  
  3327. mhandle  ds.l     1     Handle for Menu Console window
  3328.  
  3329. fhandle  ds.l     1     Handle of diskfile
  3330.  
  3331. bufptr   ds.l     1     Pointer to Capture Buffer
  3332.  
  3333. ubufptr  ds.l     1     Pointer to Uploading text pointer
  3334.  
  3335. bufstart ds.l     1     Pointer to Start Of Buffer
  3336.  
  3337. buflen   ds.l     1     Total maximum size of buffer
  3338.  
  3339. cbuff    ds.l     1     Character Buffer, 1 byte used
  3340.  
  3341. textptr  ds.l     1     Ptr to intext buffer
  3342.  
  3343. lengthin ds.l     1     Length of text in intext
  3344.  
  3345.  
  3346.  
  3347. bufin    ds.l    1      Serial Input Buffer
  3348.  
  3349. bufout   ds.l    1      Serial Output Buffer
  3350.  
  3351. baud     ds.l    1      Current baud rate
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357. * Words
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363. * Bytes
  3364.  
  3365.  
  3366.  
  3367.          cnop     0,4
  3368.  
  3369. fileflag ds.b     1     Flag indicating Up/Download status
  3370.  
  3371. duplex   ds.b     1     Full Duplex=0, Half Duplex=$ff
  3372.  
  3373. squalking ds.b    1     Squalking enabled=0
  3374.  
  3375. block    ds.b     1     Block number
  3376.  
  3377.          cnop     0,4
  3378.  
  3379.  
  3380.  
  3381. endbss
  3382.  
  3383.  
  3384.  
  3385.  
  3386.  
  3387.          end
  3388.  
  3389.  
  3390.